//
//  RenheViewController.m
//  BigToBig
//
//  Created by 毛丽媛 on 16/7/8.
//  Copyright © 2016年 cn.cloudtp. All rights reserved.
//

#import "RenheViewController.h"
#import "RenHePartnerViewController.h"
#import "RenHeTeacherViewController.h"

@interface RenheViewController ()

@property (nonatomic , strong)UISegmentedControl *tabSegmented;
@property (nonatomic , strong)RenHePartnerViewController *partnerVC;
@property (nonatomic , strong)RenHeTeacherViewController *teacherVC;

@end

@implementation RenheViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = COLOR_RGBA(69,164,250,1);
    
    [self createTabSegmentedControl];
    [self createViews];
    
}

#pragma mark - 设置tabbar
- (void)createTabSegmentedControl{
    NSArray *segmentedArr = @[@"创业伙伴",@"创业导师"];
    self.tabSegmented = [[UISegmentedControl alloc]initWithItems:segmentedArr];
    _tabSegmented.tintColor = [UIColor whiteColor];
    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor, [UIFont fontWithName:@""size:18],UITextAttributeFont ,[UIColor whiteColor],UITextAttributeTextShadowColor ,nil];
    [_tabSegmented setBackgroundColor:COLOR_RGBA(100,181,252,1)];
    _tabSegmented.apportionsSegmentWidthsByContent = NO;
    [_tabSegmented setTitleTextAttributes:dic forState:UIControlStateNormal];
    _tabSegmented.layer.borderColor = [[UIColor whiteColor] CGColor];
    _tabSegmented.layer.borderWidth = 2;
    _tabSegmented.layer.cornerRadius = 5;
    _tabSegmented.layer.masksToBounds = YES;
    _tabSegmented.frame = CGRectMake(0, 0, kScreenWidth / 5 * 3, 30);
    _tabSegmented.center = CGPointMake(kScreenWidth / 2, 32);
    self.navigationItem.titleView = self.tabSegmented;
    [_tabSegmented setSelectedSegmentIndex:0];
    [_tabSegmented addTarget:self action:@selector(tabSegmentedAction:) forControlEvents:UIControlEventValueChanged];
}

- (void)createViews{
    self.partnerVC = [[RenHePartnerViewController alloc]init];
    [self addChildViewController:_partnerVC];
    
    // 设置初始是partnerVC 显示
    [self.view addSubview:self.partnerVC.view];
    
    self.teacherVC = [[RenHeTeacherViewController alloc]init];
    [self addChildViewController:_teacherVC];

}

- (void)tabSegmentedAction:(UISegmentedControl *)segmentControl{
    if (segmentControl.selectedSegmentIndex == 0) {
        [self.view addSubview:self.partnerVC.view];
    }
    else{
        [self.view addSubview:self.teacherVC.view];
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
